package com.example.demo.controller;

import com.example.demo.pojo.liaotianneirong;
import com.example.demo.pojo.wanfaa;
import com.example.demo.service.sv.wanfa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("wanfa")
public class wanfacontroller {
    @Autowired
    wanfa wanfa;
     @RequestMapping("fangjianxinxi")
     @ResponseBody
     public wanfaa fangjianxinxi(@RequestParam("fangjianid")int fangjianid)
     {
         return wanfa.fangjianxinxi(fangjianid);
     }
    @RequestMapping("kaishipipei")
    @ResponseBody
    public wanfaa kaishipipei(@RequestParam("zhang") String zhang){
         return wanfa.kaishipipei(zhang);

    }
    @RequestMapping("jieshupipei")
    @ResponseBody
    public int jiehsupipei(@RequestParam("zhang")String zhang){
        return  wanfa.jieshupipei(zhang);
    }

    @RequestMapping("qiangdizhu")
    @ResponseBody
    public void qiandizhu(@RequestParam("fangjianid")int fangjianid,@RequestParam("xuhao") int xuhao){
        wanfa.qiangdizhu(fangjianid,xuhao);
    }
    @RequestMapping("buqiangdizhu")
    @ResponseBody
    public void buqiandizhu(@RequestParam("fangjianid")int fangjianid,@RequestParam("xuhao") int xuhao){
        wanfa.buqiangdizhu(fangjianid,xuhao);
    }
    @RequestMapping("fenpai")
    @ResponseBody
    public void fenpai(@RequestParam("fangjianid")int fangjianid,@RequestParam("xuhao") int xuhao){
         wanfa.fenpai(fangjianid,xuhao);
    }
    @RequestMapping("querendizhu")
    @ResponseBody
    public wanfaa querendizhu(@RequestParam("fangjianid")int fangjianid){
       return wanfa.querendizhu(fangjianid);
    }
    @RequestMapping("chupai")
    @ResponseBody
    public void chupai(@RequestParam("fangjianid")int fangjianid,@RequestParam("xuhao") int xuhao,@RequestParam("chupaishu") int chupaishu,@RequestParam("chupai")String chupai){
         wanfa.chupai(fangjianid,xuhao,chupaishu,chupai);
    }
    @RequestMapping("buyao")
    @ResponseBody
    public void buyao(@RequestParam("fangjianid")int fangjianid,@RequestParam("xuhao") int xuhao){
        wanfa.buyao(fangjianid,xuhao);
    }
    @RequestMapping("bidaxiao")
    @ResponseBody
    public int bidaxiao(@RequestParam("fangjianid")int fangjianid, @RequestParam("chupai") String chupai){
        List<Integer> cp=new ArrayList<>();
        String [] cpps=chupai.split(",");
        for(String cpp : cpps){
            cp.add(Integer.parseInt(cpp));
        }

       return wanfa.bidaxiao(fangjianid,cp);
    }
    @RequestMapping("chaliaotianneirong")
    @ResponseBody
    public List<liaotianneirong> chaliaotianneirong(@RequestParam("fangjianid")int fangjianid){
        return   wanfa.chaliaotianneirong(fangjianid);
    }
    @RequestMapping("jiaoliu")
    @ResponseBody
    public void jiaoliu(@RequestParam("fangjianid")int fangjianid,@RequestParam("zhang")String zhang,@RequestParam("neirong")String  neirong){
          wanfa.jiaoliu(fangjianid,zhang,neirong);
    }
}
